package com.ruoyi.web.controller.lwpq;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lwpq.domain.LwpqSbjfgl;
import com.ruoyi.lwpq.service.ILwpqSbjfglService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社保缴费管理Controller
 * 
 * @author ruoyi
 * @date 2022-03-10
 */
@Controller
@RequestMapping("/lwpq/sbjfgl")
public class LwpqSbjfglController extends BaseController
{
    private String prefix = "lwpq/sbjfgl";

    @Autowired
    private ILwpqSbjfglService lwpqSbjfglService;

    @RequiresPermissions("lwpq:sbjfgl:view")
    @GetMapping()
    public String sbjfgl()
    {
        return prefix + "/sbjfgl";
    }

    /**
     * 查询社保缴费管理列表
     */
    @RequiresPermissions("lwpq:sbjfgl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LwpqSbjfgl lwpqSbjfgl)
    {
        startPage();
        lwpqSbjfgl.setCreateBy(getLoginName());
        List<LwpqSbjfgl> list = lwpqSbjfglService.selectLwpqSbjfglList(lwpqSbjfgl);
        return getDataTable(list);
    }

    /**
     * 导出社保缴费管理列表
     */
    @RequiresPermissions("lwpq:sbjfgl:export")
    @Log(title = "社保缴费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LwpqSbjfgl lwpqSbjfgl)
    {
        List<LwpqSbjfgl> list = lwpqSbjfglService.selectLwpqSbjfglList(lwpqSbjfgl);
        ExcelUtil<LwpqSbjfgl> util = new ExcelUtil<LwpqSbjfgl>(LwpqSbjfgl.class);
        return util.exportExcel(list, "社保缴费管理数据");
    }

    /**
     * 新增社保缴费管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存社保缴费管理
     */
    @RequiresPermissions("lwpq:sbjfgl:add")
    @Log(title = "社保缴费管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LwpqSbjfgl lwpqSbjfgl)
    {
        lwpqSbjfgl.setCreateBy(getLoginName());
        return toAjax(lwpqSbjfglService.insertLwpqSbjfgl(lwpqSbjfgl));
    }

    /**
     * 修改社保缴费管理
     */
    @RequiresPermissions("lwpq:sbjfgl:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        LwpqSbjfgl lwpqSbjfgl = lwpqSbjfglService.selectLwpqSbjfglById(id);
        mmap.put("lwpqSbjfgl", lwpqSbjfgl);
        return prefix + "/edit";
    }

    /**
     * 修改保存社保缴费管理
     */
    @RequiresPermissions("lwpq:sbjfgl:edit")
    @Log(title = "社保缴费管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LwpqSbjfgl lwpqSbjfgl)
    {
        lwpqSbjfgl.setUpdateBy(getLoginName());
        return toAjax(lwpqSbjfglService.updateLwpqSbjfgl(lwpqSbjfgl));
    }

    /**
     * 删除社保缴费管理
     */
    @RequiresPermissions("lwpq:sbjfgl:remove")
    @Log(title = "社保缴费管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(lwpqSbjfglService.deleteLwpqSbjfglByIds(ids));
    }
}
